package tec;




public class PassagerStandard 
    extends Passager
    implements Usager  {
    
 
    
    private final String nom;
    private final int destination;
    private EtatPassager monEtat;
    
    
    public PassagerStandard(String nom, int destination){
	this.nom = nom;
	this.destination = destination;
	monEtat = EtatPassager.DEHORS;
    }

    

    
    
    public String nom() {
	return this.nom;
    }

     boolean estDehors() {
	return monEtat.estExterieur();
    }

     boolean estAssis(){
	return monEtat.estAssis();
    }

     boolean estDebout() {
	return monEtat.estDebout();
    }

     void accepterSortie() {
	monEtat = EtatPassager.DEHORS;
    }

     void accepterPlaceAssise() {
	monEtat = EtatPassager.ASSIS;
	
    }

     void accepterPlaceDebout() {
	monEtat = EtatPassager.DEBOUT;
    }

     void nouvelArret(Bus bus, int numeroArret) {
	if(destination <= numeroArret){
	    bus.demanderSortie(this);
	}
    }

    public void monterDans(Transport t) { 
	Bus b = (Bus) t;
	if(b.aPlaceAssise())
	    b.demanderPlaceAssise(this);
	else{
	    if(b.aPlaceDebout())
		b.demanderPlaceDebout(this);
	}
    }

    @Override
	public String toString() {
	
	return nom() + " " + monEtat.toString();
    }
}

